package org.jbrisk.matchers;

import java.net.URL;

import org.hamcrest.Description;
import org.jbrisk.exceptions.NullArgumentException;
import org.junit.internal.matchers.TypeSafeMatcher;

/**
 * Compares the string representation of two {@link URL} instances.
 * 
 * @author Rafael
 * 
 */
public class URLMatcher extends TypeSafeMatcher<URL> {

	private URL url;
	
	public URLMatcher(URL url) {
		
		if (url == null) 
			throw new NullArgumentException("url");
		
		this.url = url;
	}

	public URL getURL() {
		
		return url;
	}
	
	@Override
	public void describeTo(Description arg0) {

		arg0.appendText(url.toString());
	}

	@Override
	public boolean matchesSafely(URL item) {

		return url.toString().equals(item.toString());
	}

}
